package edu.gdkm.sql.dao;

import edu.gdkm.sql.pojo.Productdetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductdetailMapper {

    // 查询全部商品详情
    @Select("SELECT * FROM productdetail")
    List<Productdetail> findAll();

    // 根据id查询商品详情
    @Select("SELECT * FROM productdetail WHERE productid = #{productid}")
    Productdetail findByProductId( int id);

    // 插入商品详情
    @Insert("INSERT INTO productdetail(goodspicurl, goodsdes, stock, brand, productid) VALUES(#{goodspicurl}, #{goodsdes}, #{stock}, #{brand}, #{productid})")
    int insertproductdetail(Productdetail productdetail);

    // 更新商品详情
    @Update("UPDATE productdetail SET goodspicurl=#{goodspicurl}, goodsdes=#{goodsdes}, stock=#{stock}, brand=#{brand}, productid=#{productid} WHERE id=#{id}")
    int updateproductdetail(Productdetail productdetail);

    // 删除商品详情
    @Delete("DELETE FROM productdetail WHERE id=#{id}")
    int deleteproductdetailById(int id);
}